package com.geek.gkpush.framework.event.model;

import com.geek.gkpush.framework.event.core.AbstractEventMsgHandler;
import com.geek.gkpush.framework.event.enums.PushStatusEnum;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.io.Serializable;
import java.util.Date;

/**
 * <h1>事件消息上下文对象，主要是解决消息从接收到消息被异步线程执行完成，整个过程的数据传递媒介而已。</h1><br/>
 *
 * <h1><br/><a href="https://u.geekbang.org/subject/arch3/100614201">Java 业务架构实战营：https://u.geekbang.org/subject/arch3/100614201</a></h1><br/><h1><a href="https://gitee.com/ylimhhmily/BizArchPracticeCamp">Java 业务架构实战营代码地址：https://gitee.com/ylimhhmily/BizArchPracticeCamp</a></h1><br/><h1><a href="https://u.geekbang.org/subject/java4th/1001148?source=app_share">高级 Java 工程体系课 2023 版：https://u.geekbang.org/subject/java4th/1001148?source=app_share</a></h1><br/><h1><a href="https://time.geekbang.org/column/intro/100312101?tab=catalog">Dubbo 源码剖析与实战：https://time.geekbang.org/column/intro/100312101?tab=catalog</a></h1>
 *
 * @author hmilyylimh
 *         ^_^
 * @version 0.0.1
 *         ^_^
 * @date 2023/10/2
 *
 */
@Setter
@Getter
@ToString(callSuper = true)
public class EventMsgContext implements Serializable {

    private static final long serialVersionUID = -1340257154787798503L;

    /**
     * <h2>默认的构造方法。</h2>
     */
    public EventMsgContext() {
        startTime = new Date();
    }

    /** <h2>创建消息上下文的开始时间</h2> **/
    private Date startTime;
    /** <h2>创建时间</h2> **/
    private Long createTime;

    /** <h2>t_push_event_msg 表的 id</h2> **/
    private String id;

    /** <h2>业务ID</h2> **/
    private String bizId;
    /** <h2>{@linkplain AbstractEventMsgHandler} 实现类的 beanName。</h2> **/
    private String bizType;

    /** <h2>消息内容</h2> **/
    private String msgContent;
    /** <h2>当前推送状态，详见 {@linkplain PushStatusEnum} 枚举类</h2> **/
    private String pushStatus;

    /**
     * <h2>获取 bizType + bizId 的唯一值。</h2>
     *
     * @return
     */
    public String toUniqueKey() {
        return EventMsgDTO.toUniqueKey(getBizType(), getBizId());
    }
}